Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
vuejs via CDN "Uncaught TypeError: remove is not a function"

I'm importing Vue.js by CDN, and the "remove" method didn't work:

      <sidebar 
  :cart="cart" 
  :remove="removeItem"
  />
    <script src="https://unpkg.com/vue@next"></script>
    <script>
  let app = Vue.createApp({
    data() {
      return {
        cart: {}
      }
    },
    methods: {
      addToCart(name,index) {
        if (!this.cart[name]) this.cart[name]=0
        this.cart[name] += this.inventory[index].quantity
        this.inventory[index].quantity=0
      },
      removeItem(name){
        delete this.cart[name]
      }
  })
  app.component('sidebar',{
    props:['cart','remove'],
    template:`      
    <aside class="cart-container">
          <tbody>
            <tr v-for="(quantity,key,i) in cart" :key="i">
              <td><i class="icofont-carrot icofont-3x"></i></td>
              <td>{{key}}</td>
              <td>\${{getPrice(key)}}</td>
              <td class="center">{{quantity}}</td>
              <td>\${{ (quantity*getPrice(key)).toFixed(2) }}</td>
              <td class="center">
                <button @click="remove(key)" class="btn btn-light cart-remove">
                  &times;
                </button>
              </td>
            </tr>
          </tbody>

the google chrome gave the error that:

the error info

I'm told that this workaround only shows up when using CDN not npm. But I still wonder why "remove" here isn't considered as a function. Thx ahead.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!